#include <iostream>
#include <thread>
#include <string>

class X
{
private:
    std::string m_data;

public:
    X() = default;
    X(std::string data) : m_data(data) {}
    ~X() = default;

    void do_something()
    {
        std::cout << "do something" << std::endl;
    }
    void do_something_with_param(std::string msg)
    {
        std::cout << "do something: " << msg << std::endl;
    }
};

int main()
{
    X x{"old value"};
    // 如果想将某个类的成员函数作为线程函数，应该传入一个函数指针，指向该成员函数
    std::thread t(&X::do_something, &x);
    t.join();
    std::thread t2(&X::do_something_with_param,&x,std::string("message"));
    t2.join();
    return 0;
}
